package com.yuzhihao.writejvm.exce;

import com.yuzhihao.writejvm.clazz.ClassInfo;
import com.yuzhihao.writejvm.code.Operation;
import com.yuzhihao.writejvm.code.StackFrame;
import com.yuzhihao.writejvm.constant.ConstantPool;
import com.yuzhihao.writejvm.method.MethodInfo;
import com.yuzhihao.writejvm.run.ParseRun;

import java.lang.reflect.Field;
import java.util.Stack;

/**
 * 解释器
 *
 * @author yzh
 * @since 2021年12月16日14:54:04
 */
public class Interpreter {

    public static void main(String[] args) {
        ClassInfo info = ParseRun.getClass("/Users/yzh/aliyun/java/yuzhihaolearn/jvm1/target/classes/jvm/parse/ParseClass.class");

        //找到main方法
        for (MethodInfo methodInfo : info.getMethod_info().getInfos()) {
            int name_index = methodInfo.getName_index();
            ConstantPool cp = info.getCp_info().getPools().get(String.valueOf(name_index));
            if("main".equals(cp.getConstant())){
                methodInfo.exec(null);
                break;
            }


        }

    }




}
